package com.zx._01_基础.浅拷贝and深拷贝.beanUtil;

import java.lang.reflect.InvocationTargetException;
import org.springframework.beans.BeanUtils;

public class Main {

    /**
     * 深复制演示
     *
     * @param args
     * @throws CloneNotSupportedException
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     * @Description:
     * @date: 2018年4月14日下午10:28:26
     */
    public static void main(String[] args)
            throws CloneNotSupportedException, IllegalAccessException, InvocationTargetException {
        User u1 = new User(1, new Name("大名", "小名"));
        System.out.println("原对象:\t\t" + u1);

        User u2 = new User();
        BeanUtils.copyProperties(u1, u2);

        System.out.println("复制获得:\t" + u2);
        System.out.println("u1==u2 : " + u1.equals(u2));

        System.out.println("修改原对象FirstName=2333");
        u1.getName().setFirstName("2333");

        System.out.println("修改后原对象:\t" + u1);
        System.out.println("修改后复制的对象:\t" + u2);
    }

}
